package com.imooc.reader.management.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.imooc.reader.management.entity.Menu;
import com.imooc.reader.management.entity.User;
import com.imooc.reader.management.mapper.MenuMapper;
import com.imooc.reader.management.mapper.UserMapper;
import com.imooc.reader.management.service.MenuService;
import com.imooc.reader.management.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MenuServiceImpl implements MenuService {
    @Resource
    private UserMapper userMapper;
    @Resource
    private MenuMapper menuMapper;
    @Override
    public List<Menu> selectByUsername(String username) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("username", username);
        User user = userMapper.selectOne(wrapper);
        List<Menu> menus = menuMapper.selectByUserId(user.getUserId());
        return menus;
    }
}
